local require = GLOBAL.require

local STRINGS = GLOBAL.STRINGS
local RECIPETABS = GLOBAL.RECIPETABS
local TECH = GLOBAL.TECH

local Recipe = GLOBAL.Recipe
local Ingredient = GLOBAL.Ingredient

-- Ingredient 1
local Component1 = GetModConfigData("Component1") or 0
local Amount1 = GetModConfigData("Amount1") or 0

-- Ingredient 2
local Component2 = GetModConfigData("Component2") or 0
local Amount2 = GetModConfigData("Amount2") or 0

-- Ingredient 3
local Component3 = GetModConfigData("Component3") or 0
local Amount3 = GetModConfigData("Amount3") or 0

-- Crafting Conditions
local CraftTab = GetModConfigData("CraftTab") or 0
local CraftStation = GetModConfigData("CraftStation") or 0
local AmountCrafted = GetModConfigData("AmountCrafted") or 0

-- Recipe description.
STRINGS.RECIPE_DESC.GEARS = "各种机械零件"

-- Create empty variables.
local RecipeCost = {}

-- Fill empty variables.

-- Ingredient 1
if (Component1 == 0) then
	print("None selected")
elseif (Component1 == 1) then
	RecipeCost[#RecipeCost + 1] = GLOBAL.Ingredient("cutstone", Amount1);
elseif (Component1 == 2) then
	RecipeCost[#RecipeCost + 1] = GLOBAL.Ingredient("transistor", Amount1);
elseif (Component1 == 3) then
	RecipeCost[#RecipeCost + 1] = GLOBAL.Ingredient("flint", Amount1);
elseif (Component1 == 4) then
	RecipeCost[#RecipeCost + 1] = GLOBAL.Ingredient("goldnugget", Amount1);
elseif (Component1 == 5) then
	RecipeCost[#RecipeCost + 1] = GLOBAL.Ingredient("purplegem", Amount1);
elseif (Component1 == 6) then
	RecipeCost[#RecipeCost + 1] = GLOBAL.Ingredient("steelwool", Amount1);
end

	-- Ingredient 2
if (Component2 == 0) then
	print("None selected")
elseif (Component2 == 1) then
	RecipeCost[#RecipeCost + 1] = GLOBAL.Ingredient("cutstone", Amount2);
elseif (Component2 == 2) then
	RecipeCost[#RecipeCost + 1] = GLOBAL.Ingredient("transistor", Amount2);
elseif (Component2 == 3) then
	RecipeCost[#RecipeCost + 1] = GLOBAL.Ingredient("flint", Amount2);
elseif (Component2 == 4) then
	RecipeCost[#RecipeCost + 1] = GLOBAL.Ingredient("goldnugget", Amount2);
elseif (Component2 == 5) then
	RecipeCost[#RecipeCost + 1] = GLOBAL.Ingredient("purplegem", Amount2);
elseif (Component2 == 6) then
	RecipeCost[#RecipeCost + 1] = GLOBAL.Ingredient("steelwool", Amount2);
end

-- Ingredient 3
if (Component3 == 0) then
	print("None selected")
elseif (Component3 == 1) then
	RecipeCost[#RecipeCost + 1] = GLOBAL.Ingredient("cutstone", Amount3);
elseif (Component3 == 2) then
	RecipeCost[#RecipeCost + 1] = GLOBAL.Ingredient("transistor", Amount3);
elseif (Component3 == 3) then
	RecipeCost[#RecipeCost + 1] = GLOBAL.Ingredient("flint", Amount3);
elseif (Component3 == 4) then
	RecipeCost[#RecipeCost + 1] = GLOBAL.Ingredient("goldnugget", Amount3);
elseif (Component3 == 5) then
	RecipeCost[#RecipeCost + 1] = GLOBAL.Ingredient("purplegem", Amount3);
elseif (Component3 == 6) then
	RecipeCost[#RecipeCost + 1] = GLOBAL.Ingredient("steelwool", Amount3);
end

-- If choosing Magictab set station here.
if (CraftTab == 1) and (CraftStation == 1) then
	AddRecipe("gears", RecipeCost, RECIPETABS.MAGIC, TECH.SCIENCE_ONE, nil, nil, nil, AmountCrafted, nil)
elseif (CraftTab == 1) and (CraftStation == 2) then
	AddRecipe("gears", RecipeCost, RECIPETABS.MAGIC, TECH.SCIENCE_TWO, nil, nil, nil, AmountCrafted, nil)
elseif (CraftTab == 1) and (CraftStation == 3) then
	AddRecipe("gears", RecipeCost, RECIPETABS.MAGIC, TECH.MAGIC_ONE, nil, nil, nil, AmountCrafted, nil)
elseif (CraftTab == 1) and (CraftStation == 4) then
	AddRecipe("gears", RecipeCost, RECIPETABS.MAGIC, TECH.MAGIC_TWO, nil, nil, nil, AmountCrafted, nil)
elseif (CraftTab == 1) and (CraftStation == 5) then
	AddRecipe("gears", RecipeCost, RECIPETABS.MAGIC, TECH.NONE, nil, nil, nil, AmountCrafted, nil)
end

-- If choosing Refinetab set station here.
if (CraftTab == 2) and (CraftStation == 1) then
	AddRecipe("gears", RecipeCost, RECIPETABS.REFINE, TECH.SCIENCE_ONE, nil, nil, nil, AmountCrafted, nil)
elseif (CraftTab == 2) and (CraftStation == 2) then
	AddRecipe("gears", RecipeCost, RECIPETABS.REFINE, TECH.SCIENCE_TWO, nil, nil, nil, AmountCrafted, nil)
elseif (CraftTab == 2) and (CraftStation == 3) then
	AddRecipe("gears", RecipeCost, RECIPETABS.REFINE, TECH.MAGIC_ONE, nil, nil, nil, AmountCrafted, nil)
elseif (CraftTab == 2) and (CraftStation == 4) then
	AddRecipe("gears", RecipeCost, RECIPETABS.REFINE, TECH.MAGIC_TWO, nil, nil, nil, AmountCrafted, nil)
elseif (CraftTab == 2) and (CraftStation == 5) then
	AddRecipe("gears", RecipeCost, RECIPETABS.REFINE, TECH.NONE, nil, nil, nil, AmountCrafted, nil)
end

-- If choosing Sciencetab set station here.
if (CraftTab == 3) and (CraftStation == 1) then
	AddRecipe("gears", RecipeCost, RECIPETABS.SCIENCE, TECH.SCIENCE_ONE, nil, nil, nil, AmountCrafted, nil)
elseif (CraftTab == 3) and (CraftStation == 2) then
	AddRecipe("gears", RecipeCost, RECIPETABS.SCIENCE, TECH.SCIENCE_TWO, nil, nil, nil, AmountCrafted, nil)
elseif (CraftTab == 3) and (CraftStation == 3) then
	AddRecipe("gears", RecipeCost, RECIPETABS.SCIENCE, TECH.MAGIC_ONE, nil, nil, nil, AmountCrafted, nil)
elseif (CraftTab == 3) and (CraftStation == 4) then
	AddRecipe("gears", RecipeCost, RECIPETABS.SCIENCE, TECH.MAGIC_TWO, nil, nil, nil, AmountCrafted, nil)
elseif (CraftTab == 3) and (CraftStation == 5) then
	AddRecipe("gears", RecipeCost, RECIPETABS.SCIENCE, TECH.NONE, nil, nil, nil, AmountCrafted, nil)
end